package com.projeto.bola.web.email;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
import org.apache.log4j.Logger;


public class EmailUtils
{
	Email email;
	public EmailUtils() {
		email =  new SimpleEmail();
		ConfiguraEmail();
	}
	
	private void ConfiguraEmail(){
		email.setHostName("smtp.googlemail.com");
		email.setSmtpPort(465);
		email.setAuthentication("sistema.bolanarede.bsb@gmail.com", "sistema123");
		email.setSSLOnConnect(true);	
	}
	
	public void EnviarEmail(String from, String sub, String msg, String to){
		try {				
			email.setFrom(from);		
			email.setSubject(sub);
			email.setMsg(msg);
			email.addTo(to);
			email.addReplyTo(from);
			email.send();
			} catch (EmailException ex) {			
			Logger.getLogger(EmailUtils.class.getName()).log(null,ex);
		}
	}
      
}
